import asteroids.exception.OverflowException;


public class ExtMath {

	public static boolean areAddable(double a, double b) {
		if ((a > 0) && (b > 0))
			return a <= Double.MAX_VALUE - b;
		if ((a < 0) && (b < 0))
			return a >= Double.MIN_VALUE - b;
		return true;
	}
	
	public static double add(double a, double b) throws OverflowException {
		if (!areAddable(a, b))
			throw new OverflowException();
		return a + b;
	}
}